<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue+Axios读取数据</title>
</head>
<body>
<!-- 在Html页面中完成和后台交互的方法 -->
<!-- 1.Javascript的Ajax实现 -->
<!-- 2.Jquery对Ajax进行封装：load()，$.ajax()，$.post()，$.get()，$.getJSON() -->
<div id="app">
    <h1>读取数据库</h1>
    <button id="axios_vue">获取用户(Axios+Vue方式)</button>
    <table border="1" style="margin-top: 20px">
        <thead>
        <tr>
            <th>ID</th>
            <th>用户名</th>
            <th>密码</th>
            <th>邮箱</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="item in list">
            <td>{{item.id}}</td>
            <td>{{item.username}}</td>
            <td>{{item.password}}</td>
            <td>{{item.email}}</td>
        </tr>
        </tbody>
    </table>
</div>
<script src="js/jquery-2.1.0.min.js"></script>
<script src="js/axios.js"></script>
<script src="js/vue.js"></script>
<script>

    var vm = new Vue({
        el:'#app',
        data:{
            list:{}
        }
    });

    $('#axios_vue').on('click', function () {
        axios.get('http://localhost:8080/users/findAll').then(function (result) {
            vm.list = result.data;
        });
    });
</script>
</body>
</html>